package com.example.teacher.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.teacher.R
import com.example.teacher.data.Class

/**
 *@Created by 覃德玮 on 2021/9/19 11:37
 *@Email: chadewik@foxmail.com
 *@Description:
 */
class CourseStuListAdapter(data: List<Class>) : RecyclerView.Adapter<MyHolder>() {
    val data = data

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {
        val holder = MyHolder(
            LayoutInflater.from(parent.context).inflate(R.layout.stu_item, parent, false)
        )
        return holder
    }

    override fun onBindViewHolder(holder: MyHolder, position: Int) {
        holder.name.text = data[position].name
        holder.id.text = data[position].stuId
    }

    override fun getItemCount(): Int {
        return data.size
    }


}

class MyHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
    val name: TextView = itemView.findViewById(R.id.stu_name)
    val id: TextView = itemView.findViewById(R.id.stu_id)
}